<?php
$con = mysql_connect("localhost","gsdbadmin","atdt911");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}
mysql_select_db("gsdata");
$SQL = "SELECT * FROM skill_type ORDER BY name";
$result = mysql_query($SQL);
$search = htmlentities($_GET["skill"]);
$self = htmlentities($_SERVER['PHP_SELF']);

if ($search != NULL)
{
	$SQL = "SELECT st.`name`,stats.`name` AS `stat`,st.`untrained`,st.`action`,st.`desc`,st.`uses`,sf.`name` AS `family` ,sf.`desc` AS `family_desc`
 FROM `skill_type` st
JOIN skill_family sf ON (sf.idskill_family = st.family)
JOIN stats ON (stats.idstats = st.ability)
LEFT JOIN skill_tags_map stag ON (stag.idskill = st.idskill)
LEFT JOIN skill_synergy_map sm ON (sm.idskill = st.idskill)
WHERE st.`idskill` = ".$search;
	$result = mysql_query($SQL);
	$db_field = mysql_fetch_assoc($result);
	
print "<html><body><form action=\"".$self."\" method=\"get\">";
print "<div style=\"font-family:arial;font-size:8pt width:350px;line-height:10.5pt\">";
print "  <div style=\"background-color:#201F41;color:#FFFFFF;padding:2px 5px 0px 5px; height:28px;\">";
print "    <div style=\"font-weight:bold;float:left;\">".$db_field['name']."</div>";
print "    <div style=\"font-weight:bold;float:right;\">".$db_field['family']."</div>";
print "    <br/>";
print "    <div style=\"float:left;font-size:7pt;\">".$db_field['stat']."</div>";
print "    <div style=\"float:right;font-size:7pt;\">".$db_field['idskill_tag']."</div>";
print "  </div>";
print "  <div style=\"background-color:#ddddcc;background-image:url('http://omnichron.net/external/op/src/bg_350.jpg');font-style:italic;padding:0px 0px 3px 5px;\">";
print $db_field['desc'];
print "  </div>";
print "  <div style=\"background-color:#dcdcdc;padding:0px 0px 3px 5px;\">";
print "    <b>Untrained</b> ".$db_field['untrained']." &#9830; <b>Action</b> ".$db_field['action']."<br/>";
print "    <b>Counter Bonus</b> ".$db_field['idcounter_bonus']." &#9830; <b>Opposed</b> ".$db_field['opposed']."<br/>";
print "  </div>";
print "  <div style=\"background-color:#FFFFFF;padding:3px 0px 3px 5px;\">";
print "    <b>Uses</b> ".$db_field['uses'];
print "  </div>";
print "  <div style=\"background-color:#dcdcdc;padding:0px 0px 3px 5px;\">";
print $db_field['idsynergy'];
print "  </div>";
print "</div>";
print "<p/><input type=\"submit\" value=\"Search another\">";
print "</form></body></html>";
	
} else {
print "<html><body><form action=\"".$self."\" method=\"get\">";
print "<fieldset>";
print "<legend>Skill Check Selection</legend>";
print "Select the skill check<br/>";
print "<select name=\"skill\">";
while ($db_field = mysql_fetch_assoc($result)) {
	print "<option value=\"".$db_field['idskill']."\">".$db_field['name']."</option>";
}
print "</select>";
print "<p/>";
print "<input type=\"submit\" value=\"Submit\">";
print "</fieldset>";
print "</form></body></html>";
}
?>

